#ifndef MAIN_H_INCLUDED
#define MAIN_H_INCLUDED

#include "ascii.h"
#include "charTypes.h"
#include "mnemonics.h"
#include "inputTypes.h"

#define MAX_STRING_LEN 256
#define MAX_PROGRAM_LEN 256
#define MAX_LABELS 256
#define BYTE_SIZE 256

struct label
{
    int type;
    int address;
    int value;
    int arrayLen;
    int * array;
    char * name;
};

struct program
{
    int currentByte;
    int bytes[MAX_PROGRAM_LEN];
};

struct labelManager
{
    int currentLabel;
    struct label labels[MAX_LABELS];
};


extern const char * testprogram;
extern int pIndex;


int compile (char * errorMsg, FILE * pFile, FILE * pFileOut);
int getNextString(char * writeTo, FILE * pFile);
int validCharacter(char testChar);

int addressLabels(char * errorMsg, FILE * pFile, struct labelManager * lManager);
int parseLabels(char * errorMsg, FILE * pFile, struct labelManager * lManager);
int parseCode (char * errorMsg, FILE * pFile, struct program * prog, struct labelManager * lManager);
int assignLabels (char * errorMsg, FILE * pFile, struct program * prog, struct labelManager * lManager);

void addProgramByte (struct program * prog, int byte);
void addLabel (char * errorMsg, struct labelManager * lManager, int type, int address,
               int value, int arrayLen, int * array, char * name);

#endif // MAIN_H_INCLUDED
